package Engine.Module
{
	import Engine.Manager.EngineManager;
	
	import Interface.Module.IModuleBase;
	
	import flash.display.BitmapData;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;

	public class ViewBase extends Sprite implements IModuleBase
	{
		private var _isShow:Boolean = false;
		protected var _content:Sprite;
		
		public function ViewBase(p_content:Sprite = null)
		{
			super();
			this._content = p_content;
			if(this._content != null)
				this.addChild(this._content as Sprite);
		}
		
		public function show(p_parent:DisplayObjectContainer):void
		{
			if(_isShow)
			{
				p_parent.addChild(this);
				return;
			}
			_isShow = true;
			onShowBackPre();
			p_parent.addChild(this);
			onShowBack();
		}
		
		public function dispose():void
		{
			if(_isShow && parent != null)
			{
				_isShow = false;
				onDisposeBack();
				parent.removeChild(this);
				onDisposeBackEnd();
			}
		}
		
		
		public function get isShow():Boolean
		{
			return this._isShow;
		}
		
		protected function printLog(...msg):void
		{
			EngineManager.logPrint.printLog(msg.join(" "));
		}
		
		protected function sendMsg(msgID:int,data:*):void
		{
			EngineManager.socketMgr.sendMessageData(msgID,data);
		}
		
		protected function onShowBackPre():void
		{
			
		}
		
		protected function onDisposeBack():void
		{
			
		}
		protected function onShowBack():void
		{
			
		}
		
		protected function onDisposeBackEnd():void
		{
			
		}
	}
}